home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / s / groupdistribute.pprx < prev    next >
Text File  |  1992-03-14  |  5KB  |  216 lines

  1. /*
  2. @BGroupDistribute  @P@ICopyright Gold Disk Inc., February, 1992
  3. This Genie will redistribute the boxes in a group, evenly distributing them across a specified range. 
  4.  
  5. */
  6. cr = '0a'x
  7. address command
  8. call SafeEndEdit.rexx()
  9. call ppm_AutoUpdate(0)
  10.  
  11. units = ppm_GetUnits()
  12. if units = 3 then
  13.     call ppm_SetUnits(1)
  14.  
  15. signal on halt
  16. signal on break_c
  17. signal on break_e
  18. signal on break_d
  19.  
  20. group = ppm_GroupFirstBox()
  21. if group = 0 then exit_msg("Please select a group first")
  22.  
  23. hspacing = "Left"cr"Right"cr"Centers"cr"Boxes"cr"None"
  24. vspacing = "Top"cr"Bottom"cr"Centers"cr"Boxes"cr"None"
  25.  
  26. hspacing = ppm_SelectFromList("Horizontal Distribution..", 20, 5, 0, hspacing)
  27. if hspacing = '' then exit_msg()
  28.  
  29. vspacing = ppm_SelectFromList("Vertical Distribution..", 20, 5, 0, vspacing)
  30. if vspacing = '' then exit_msg()
  31.  
  32. vdist = 0
  33. hdist = 0
  34. grouprect   = ppm_GetGroupRect()
  35. groupleft   = word(grouprect, 1)
  36. grouptop = word(grouprect, 2)
  37. groupwidth  = word(grouprect, 3)
  38. groupheight = word(grouprect, 4)
  39. right = groupleft + groupwidth
  40. bottom   = grouptop + groupheight
  41.  
  42. if hspacing ~= "None" then
  43. do
  44.    if units = 3 then
  45.       htext = "From:" || ppm_ConvertUnits(1, 3,groupleft) || cr"To:" || ppm_ConvertUnits(1, 3, right)
  46.    else
  47.       htext = "From:"groupleft || cr"To:"right
  48.  
  49.    hdist = ppm_GetForm( "Horizontal Distribution", 8, htext)
  50.    if hdist = '' then exit_msg()
  51.  
  52.    parse var hdist startx '0a'x endx
  53.  
  54.    if ~(datatype(startx, n) & datatype(endx, n)) then
  55.        call exit_msg('Invalid Input')
  56.  
  57.    if units = 3 then
  58.    do
  59.       startx = ppm_ConvertUnits(3, 1, startx)
  60.       endx = ppm_ConvertUnits(3, 1, endx)
  61.    end
  62.  
  63.    if endx < startx then
  64.    do
  65.       temp = endx
  66.       startx = endx
  67.       endx = temp
  68.    end
  69.  
  70.  
  71. end
  72.  
  73. if vspacing ~= "None" then
  74. do
  75.    if units = 3 then
  76.       vtext = "From:" || ppm_ConvertUnits(1, 3,grouptop) || cr"To:" || ppm_ConvertUnits(1, 3, bottom)
  77.    else
  78.       vtext = "From:"grouptop || cr"To:"bottom
  79.  
  80.    vdist = ppm_GetForm( "Vertical Distribution", 8, vtext)
  81.    if vdist = '' then exit_msg()
  82.  
  83.    parse var vdist starty '0a'x endy
  84.  
  85.    if ~(datatype(starty, n) & datatype(endy, n)) then
  86.        call exit_msg('Invalid Input')
  87.    
  88.    if units = 3 then
  89.    do
  90.       starty = ppm_ConvertUnits(3, 1, starty)
  91.       endy = ppm_ConvertUnits(3, 1, endy)
  92.    end
  93.  
  94.    if endy < starty then
  95.    do
  96.       temp = endy
  97.       starty = endy
  98.       endy = temp
  99.    end
  100.  
  101.  
  102. end
  103.  
  104. counter = 0
  105. box = ppm_GroupFirstBox()
  106.  
  107. sumwidths   = 0
  108. sumheights  = 0
  109.  
  110. do while box ~= 0
  111.  
  112.    counter = counter + 1
  113.    boxes.counter = box
  114.  
  115.     boxpos  = ppm_GetBoxRect(box)
  116.    boxes.counter.0   = word(boxpos, 1) /* left  */
  117.    boxes.counter.1   = word(boxpos, 2) /* top      */
  118.    boxes.counter.2   = word(boxpos, 3) /* width */
  119.    boxes.counter.3   = word(boxpos, 4) /* height   */
  120.  
  121.    sumwidths = sumwidths + boxes.counter.2
  122.    sumheights = sumheights + boxes.counter.3
  123.  
  124.    box = ppm_GroupNextBox(box)
  125.  
  126. end
  127.  
  128. vpos  = starty
  129. hpos  = startx
  130. vmove = "vpos = vpos + vspace"
  131. hmove = "hpos = hpos + hspace"
  132.  
  133. if vspacing = "Top" then
  134. do
  135.    vspace = (endy - starty) / counter
  136.    vstring = "vpos"
  137. end
  138. else if vspacing = "Bottom" then
  139. do
  140.    vspace = (endy - starty) / counter
  141.    vstring  = "vpos - boxes.i.3"
  142. end
  143. else if vspacing = "Centers" then
  144. do
  145.    vspace = (endy - starty) / counter
  146.    vstring = "vpos - .5 * boxes.i.3"
  147. end
  148. else if vspacing = "Boxes" then
  149. do
  150.    vdist = ((endy - starty) - sumheights) / (counter + 1)
  151.    vstring = "vpos"
  152.    vmove = "vpos = vpos + boxes.i.3 + vdist"
  153. end
  154. else
  155. do
  156.    vstring = "boxes.i.1"
  157.    vmove = "/**/"
  158. end
  159.  
  160. if hspacing = "Left" then
  161. do
  162.    hspace = (endx - startx) / counter
  163.    hstring = "hpos"
  164. end
  165. else if hspacing = "Right" then
  166. do
  167.    hspace = (endx - startx) / counter
  168.    hstring  = "hpos - boxes.i.2"
  169. end
  170. else if hspacing = "Centers" then
  171. do
  172.    hspace = (endx - startx) / counter
  173.    hstring = "hpos - .5 * boxes.i.2"
  174. end
  175. else if hspacing = "Boxes" then
  176. do
  177.    hdist = ((endx - startx) - sumwidths) / (counter + 1)
  178.    hstring = "hpos"
  179.    hmove = "hpos = hpos + boxes.i.2 + hdist"
  180. end
  181. else
  182. do
  183.    hstring = "boxes.i.0"
  184.    hmove = "/**/"
  185. end
  186.  
  187. do i = 1 to counter
  188.     
  189.    interpret "x = "hstring
  190.    interpret "y = "vstring
  191.     call ppm_SetBoxPosition(boxes.i, x, y)
  192.    interpret vmove
  193.    interpret hmove
  194.  
  195. end
  196.  
  197. call exit_msg()
  198. break_d:
  199. break_e:
  200. break_c:
  201. halt:
  202.     call exit_msg("User aborted Genie!")
  203.  
  204. exit_msg: procedure expose units
  205. do
  206.     parse arg message
  207.  
  208.     if message ~= '' then
  209.         call ppm_Inform( 1, message, )
  210.  
  211.    if units = 3 then call ppm_SetUnits(3)
  212.     call ppm_AutoUpdate(1)
  213.     exit
  214.  
  215. end
  216.